<?php $this->_extends('../_layouts/blank_layout'); ?>

<?php $this->_block('contents'); ?>

<div class="main">
  <h1>权限管理</h1>
  <a href="<?php echo url('admin::permissions/refreshtable'); ?>">更新权限列表</a>
  <a href="<?php echo url('admin::permissions/makeaclfile'); ?>">更新权限文件</a>
  <a href="<?php echo url('admin::permissions/list'); ?>">权限列表</a>

<!-- 二级联动 Start -->
<script language="JavaScript">
<!--
var subcat = new Array();
// subcat[0] = new Array('10','1','=1')   ==  subcat[ 数组自增索引 ] = new Array(' 主键上级索引 ',' 显示内容 ',' 值 ')  在这里显示内容跟值一样，所以去掉一个
<?php
    $i = 0;
    foreach ($ncArr as $keys=>$values){
        foreach ($values as $value){
            echo 'subcat['.$i.'] = new Array("'.$keys.'","'.$value.'")'."\n";
            $i++;
        }
    }
?>
function changeselect1(locationid)
{
    document.form1.arr_s2.length = 0;
    document.form1.arr_s2.options[0] = new Option('==选择控制器==','');
    for (i=0; i<subcat.length; i++)
    {
        if (subcat[i][0] == locationid)
        {
            document.form1.arr_s2.options[document.form1.arr_s2.length] = new Option(subcat[i][1], subcat[i][1]);
        }
    }
    document.form1.arr_s2.options[document.form1.arr_s2.length] = new Option('显示全部控制器','');
}

function toListThisForMe(){
    location="<?php echo url('admin::permissions/list'); ?>&list_namespace="+document.form1.arr_s1.value+"&list_controller="+document.form1.arr_s2.value;
}
//-->
</script>
<form name="form1">
选择要显示的模块：
<select name="arr_s1" onChange="changeselect1(this.value)" >
    <option>==命名空间==</option>
    <?php
        foreach ($ncArr as $key=>$value){
            $url_args['list_namespace'] == $key ? $seleted = ' selected="selected"':$seleted = '';
            echo '<option value="'.$key.'" '. $seleted.'>'.$key.'</option>';
        }
    ?>
</select>
<!-- select name="arr_s2" onChange="alert(this.value)" -->
<!-- select name="arr_s2" onChange="toListThisForMe()" -->
<select name="arr_s2" onmouseover="changeselect1(document.form1.arr_s1.value)" onChange="toListThisForMe()">
    <option>==选择控制器==</option>
</select>
</form>
<!-- 二级联动 Over -->


<form action="<?php echo url('admin::permissions/update'); ?>" method="post" enctype="application/x-www-form-urlencoded" >

<table cellSpacing="0" cellPadding="2" align="center" border="0">
    <tr>
        <th width="250px">设置系统角色</th>
        <th style="width:100px;">Namespace</th>
        <th style="width:100px;">Controller</th>
        <th style="width:100px;">Action</th>
        <th style="width:250px;">描述</th>
    </tr>
  <?php foreach ($permissions as $value): ?>
    <tr>
        <td align="center">
            <select style="width:100%;" name="rbac[<?php echo h($value->permission_id); ?>]">
                <option label="ACL_NULL"      value="ACL_NULL" style="color:Gainsboro;" <?php if ($value->rbac == 'ACL_NULL') echo 'selected="selected"'; ?>>NULL</option>
                <option label="ACL_EVERYONE" value="ACL_EVERYONE" style="color:green;" <?php if ($value->rbac == 'ACL_EVERYONE') echo 'selected="selected"'; ?>>EVERYONE</option>
                <option label="ACL_HAS_ROLE" value="ACL_HAS_ROLE" style="color:blue;" <?php if ($value->rbac == 'ACL_HAS_ROLE') echo 'selected="selected"'; ?>>HAS_ROLE</option>
                <option label="ACL_NO_ROLE"  value="ACL_NO_ROLE" style="color:red;" <?php if ($value->rbac == 'ACL_NO_ROLE') echo 'selected="selected"'; ?>>NO_ROLE</option>
            </select>
        </td>
        <td align="center"><?php echo h($value->namespace); ?></td>
        <td align="center"><?php echo h($value->controller); ?></td>
        <td align="center"><?php echo h($value->action); ?></td>
        <td align="center">
            <input id='aliasname_<?php echo h($value->permission_id); ?>' name='aliasname[<?php echo h($value->permission_id); ?>]' type='text' maxlength="50" value="<?php echo nl2br(h($value->aliasname)); ?>"/>
        </td>
    </tr>
  <?php endforeach; ?>
</table>
      <input type="submit" name="btn_submit" value="提交" class="btn" />
  <?php /*分页部分*/ $this->_control('pagination', 'my-pagination', array('pagination' => $pagination,'url_args' => $url_args)); ?>

</form>

</div>


<?php $this->_endblock(); ?>



